#include "loginwidget.h"
#include "ui_loginwidget.h"

#include <QMessageBox>

LoginWidget::LoginWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::LoginWidget)
{
    ui->setupUi(this);

    QObject::connect(ui->pushButton_Login, SIGNAL(clicked()), this, SLOT(sinaStartLogin()));


}

LoginWidget::~LoginWidget()
{
    delete ui;
}

void LoginWidget::sinaLoginSuccessed(){

    emit sendToMainWidget(Sina);
}

void LoginWidget::sinaStartLogin(){

    this->pAccount = new Account;
    pAccount->setUsername(ui->lineEdit_Username->text());
    pAccount->setPassword(ui->lineEdit_Password->text());

    this->pSinaLogin = new SinaLogin(this->pAccount);
    connect(pSinaLogin,SIGNAL(loginSuccessed()),this,SLOT(sinaLoginSuccessed()));
    pSinaLogin->checkAuthStart();

}

Account* LoginWidget::getSinaAccount(){

    return this->pAccount;

}
